<?php
namespace Api\Controller;

use Think\Controller;

class ClassifyController extends Controller
{

    protected $classify_model;
    public function _initialize()
    {
        $this->classify_model = D("Common/Classify");

    }
    /**
     * 获取一级分类列表
     */
    public function getClassifyList()
    {
        $sql = 'SELECT ccs.name  FROM cmf_classify ccs  WHERE ccs.pid = 0
                ORDER BY ccs.listorder ASC';
        $result = $this->classify_model->query($sql);
        $Classifys = [];
        foreach ($result as $vo) {
            $Classifys[] = $vo['name'];
        }
        $this->returnok($Classifys, 'ok');
    }
    /*
      * 根据一级分类获取二级分类分类列表
      */
    public function getSonClassifyList()
    {
        $pid = I('pid');
        $sql = "SELECT ccs.name  FROM cmf_classify ccs  WHERE ccs.pid = $pid
                ORDER BY ccs.listorder ASC";
        $Classifys = $this->classify_model->query($sql);
        $this->returnok($Classifys, 'ok');
    }

}